#include "Object3D.h"


Object3D::Object3D(void)
{
	m_yawAngle = 0.0f;
	m_pitchAngle = 0.0f;

	m_position[0] = 0.0f;
	m_position[1] = 0.0f;
	m_position[2] = 0.0f;

	Vector3 axis;
	axis[0] = 1.0f;
	axis[1] = 0.0f;
	axis[2] = 0.0f;

	m_pitchQuat.fromAxisAngle(axis, 0);

	axis[0] = 0.0f;
	axis[1] = 1.0f;
	axis[2] = 0.0f;

	m_yawQuat.fromAxisAngle(axis, 0);
}


Object3D::~Object3D(void)
{
	
}

void Object3D::GetPosition(Vector3 pos)
{
	DinoMath::CopyVector3(pos, m_position);
}

void Object3D::SetPosition(Vector3 newPos)
{
	DinoMath::CopyVector3(m_position, newPos);
}

void Object3D::Pitch(float pitch)
{
	m_pitchAngle += pitch;

	Vector3 axis;
	axis[0] = 1.0f;
	axis[1] = 0.0f;
	axis[2] = 0.0f;

	m_pitchQuat.fromAxisAngle(axis, m_pitchAngle);
}

void Object3D::Yaw(float yaw)
{
	m_yawAngle += yaw;

	Vector3 axis;
	axis[0] = 0.0f;
	axis[1] = 1.0f;
	axis[2] = 0.0f;

	m_yawQuat.fromAxisAngle(axis, m_yawAngle);
}

float &Object3D::GetPitch()
{
	return m_pitchAngle;
}

float &Object3D::GetYaw()
{
	return m_yawAngle;
}

void Object3D::GetRotationMatrix(Matrix44 m)
{
	// COLUMN ORDER
	Quaternion result;

	result = m_yawQuat * m_pitchQuat;

	result.toMatrix(m);
}

void Object3D::GetTransformMatrix(Matrix44 m)
{
	// COLUMN ORDER
	Quaternion result;
	result = m_pitchQuat * m_yawQuat;
	result.toMatrix(m);

	m[12] = m_position[0];
	m[13] = m_position[1];
	m[14] = m_position[2];
}

void Object3D::GetTranslateMatrix(Matrix44 m)
{
	// COLUMN ORDER
	m[12] = m_position[0];
	m[13] = m_position[1];
	m[14] = m_position[2];
}